<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../axios.min.js"></script>
    <script src='../jquery-3.5.0.min.js'></script>
    <script>
        var login={
            username:'admin1',
            password:123321
        }
        //请求token
        axios({
            url:'http://182.92.83.218:7788/user/login',
            method:'POST',
            data:login
        }).then(res=>{
            // console.log('axios:',res)
            var token=res.data.data.token
            console.log(res.data.data.token)
            sessionStorage.setItem('token',token)
        })
        //请求所有用户信息
        function getUsers(){
            return axios.get('http://182.92.83.218:7788/baseUser/findAll',{
                        headers:{
                            Authorization:sessionStorage.getItem('token')
                        }
                    })
        }
        function getCategory(){
            return axios.get('http://182.92.83.218:7788/category/findAll',{
                        headers:{
                            Authorization:sessionStorage.getItem('token')
                        }
                    })
        }
        axios.all([getUsers(),getCategory()]).then(axios.spread(function(user,category){
            console.log("user:",user);
            console.log('category:',category)
        }))
    </script>
</head>
<body>
    
</body>
</html>